Ext.define('Admin.view.organization.OrganizationPieWindow', {
    extend: 'Ext.window.Window',
    alias: 'widget.organizationPieWindow',

    autoShow: true,
    modal: true,
    draggable: true,
    scrollable: true,
    autoScroll: true,
    plain: true,
    closeAction: 'close',
    closable: true,

    bodyPadding: 15,

    layout: 'fit',

    items: [{ xtype: 'organization-piechart' }],

    afterRender: function() {
        var me = this;
        me.callParent(arguments);
        me.syncSize();

        Ext.on(me.resizeListeners = {
            resize: me.onViewportResize,
            scope: me,
            buffer: 50
        });
    },

    doDestroy: function() {
        Ext.un(this.resizeListeners);
        this.callParent();
    },

    onViewportResize: function() {
        this.syncSize();
    },

    syncSize: function() {
        var width = Ext.Element.getViewportWidth(),
            height = Ext.Element.getViewportHeight();
        this.setSize(600, 600);
        this.setXY([Math.floor(width * 0.3), Math.floor(height * 0.3)]);
    }

});